home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / mnp_c.zip / MNPEVENT.C < prev    next >
C/C++ Source or Header  |  1990-05-16  |  2KB  |  102 lines

  1.  
  2. /*GLOBAL********************************************************************
  3.  
  4.     _event_wait - wait for event or timeout
  5.  
  6. ***************************************************************************/
  7.  
  8. #include <dos.h>
  9. #include <mnpdat.h>
  10.  
  11. extern USIGN_16 frame_snt,
  12.     frame_rcvd,
  13.     frame_dne;
  14.  
  15. SIGN_16 event_wait(time,flag)
  16.  
  17. USIGN_16 time,
  18.     flag;
  19. {
  20.  
  21. register USIGN_16 i;
  22.  
  23. i = 0;
  24. time -= 2;        /* to offset overhead in this routine */
  25.                 /* 2/10 of a second - just an estimate */
  26.  
  27. switch (flag)
  28.     {
  29.     
  30.     case FRAME_SND:
  31.         if (frame_snt)
  32.             {
  33.             frame_snt = FALSE;
  34.             break;
  35.             }
  36.         set_int();
  37.         for (;(frame_snt == FALSE) && (i <= time); i++)
  38.             {
  39.             suspend (1);
  40.             if (lne_stat())
  41.                 return (NO_PHYSICAL);
  42.             }
  43.         if (frame_snt)
  44.             {
  45.             frame_snt = FALSE;
  46.             return(SUCCESS);
  47.             }
  48.         else
  49.             return(TIME_OUT);
  50.  
  51.     case FRAME_RCV:
  52.         if (frame_rcvd)
  53.             {
  54.             frame_rcvd = FALSE;
  55.             break;
  56.             }
  57.         set_int();
  58.         for (;(frame_rcvd == FALSE) && (i <=time); i++)
  59.             {
  60.             suspend(1);
  61.             if (lne_stat())
  62.                 return (NO_PHYSICAL);
  63.             }
  64.         if (frame_rcvd)
  65.             {
  66.             frame_rcvd = FALSE;
  67.             return(SUCCESS);
  68.             }
  69.         else
  70.             return(TIME_OUT);
  71.  
  72.     case FRAME_DN:
  73.         if (frame_dne)
  74.             {
  75.             frame_dne = FALSE;
  76.             break;
  77.             }
  78.         set_int();
  79.         for (;(frame_dne == FALSE) && (i <= time); i++)
  80.             {
  81.             suspend (1);
  82.             if (lne_stat())
  83.                 return (NO_PHYSICAL);
  84.             }
  85.         if (frame_dne)
  86.             {
  87.             frame_dne = FALSE;
  88.             return(SUCCESS);
  89.             }
  90.         else
  91.             return(TIME_OUT);
  92.  
  93.     default:
  94.         set_int();
  95.         return(FAILURE);
  96.     }
  97.  
  98. set_int();
  99. return(SUCCESS);
  100.  
  101. }
  102.